//
//  DLoginViewController.m
//  DFrame
//
//  Created by DaiSuke on 16/8/23.
//  Copyright © 2016年 DaiSuke. All rights reserved.
//

#import "DLoginViewController.h"


@interface DLoginViewController ()<UITextFieldDelegate>

@property (nonatomic, weak) UITextField *usernameField;
@property (nonatomic, weak) UITextField *passwordField;
@property (nonatomic, weak) UIImageView *mailbgView;
@property (nonatomic, weak) UIImageView *psdbgView;
@property (nonatomic, weak) UIImageView *mailView;
@property (nonatomic, weak) UIImageView *psdView;

@end

@implementation DLoginViewController

- (void)viewDidLoad{
    [super viewDidLoad];
    
    [self setupSubviews];
    
    
    
    
    
}

- (void)setupSubviews{
    UIImageView *totalImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"login_bg"]];
    totalImageView.alpha = 0.6;
    [self.view addSubview:totalImageView];
    
    UIImageView *mailbgView = [[UIImageView alloc] init];
    mailbgView.backgroundColor = [UIColor colorWithWhite:0.4 alpha:0.6];
    [mailbgView.layer setCornerRadius:25.0];
    [mailbgView.layer setMasksToBounds:YES];
    [mailbgView bringSubviewToFront:self.view];
    [self.view addSubview:mailbgView];
    
    UIImageView *psdbgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"login_textboxbg"]];
    [psdbgView bringSubviewToFront:self.view];
    [self.view addSubview:psdbgView];
    
    UIImageView *mailView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"login_mail"]];
    [mailbgView addSubview:mailView];
    
    UIImageView *psdView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"login_password"]];
    [psdbgView addSubview:psdView];
    
    UITextField *usernameField = [[UITextField alloc] init];
    usernameField.placeholder = @"用户名";
    
    usernameField.font = DSystemFontText;
    usernameField.clearsOnBeginEditing = YES;
    usernameField.clearButtonMode = UITextFieldViewModeWhileEditing;
    usernameField.delegate = self;
    [mailbgView addSubview:usernameField];
    self.usernameField = usernameField;
    
    UITextField *passwordField = [[UITextField alloc] init];
    passwordField.placeholder = @"密码";
    passwordField.font = DSystemFontText;
    passwordField.clearsOnBeginEditing = YES;
    passwordField.clearButtonMode = UITextFieldViewModeWhileEditing;
    passwordField.delegate = self;
    [psdbgView addSubview:passwordField];
    self.passwordField = passwordField;
    
    totalImageView.frame = self.view.bounds;
    
    [mailbgView setFrame:40 y:100 w:self.view.width-80 h:50];
    [psdbgView setFrame:40 y:mailbgView.botm+10 w:self.view.width-80 h:50];
    [mailView setFrame:10 y:5 w:40 h:40];
    [psdView setFrame:10 y:5 w:40 h:40];
    [usernameField setFrame:mailView.right +10 y:15 w:mailbgView.width - 20 - 40 h:20];
    [passwordField setFrame:psdView.right +10 y:15 w:psdbgView.width - 20 - 40 h:20];
    
}

@end
